In [1]:
using JSON

In [2]:
a = [1 2 3; 4 5 6; 12 13 19]


Out[2]:
3x3 Array{Int64,2}:
  1   2   3
  4   5   6
 12  13  19

In [3]:
JSON.json(a)


Out[3]:
"[[1,4,12],[2,5,13],[3,6,19]]"

This JSON is fairly simple

Simple datastructures result in simple JSON that the JSON module can handle on its own. For more complex datastructures, especially those involving DataFrames, you may have to write your own helper function.

Keep in mind that Julia's arrays are stored in column major order, which means iterating over a single column at a time is very fast compared to iterating a row at a time.

We'll now send this data to the client

We use the display method to write something from the julia kernel to the browser running IPython


In [4]:
display("text/html", """
Adding script tag here:
<script type="text/javascript">
    var a = $(JSON.json(a));
    if (typeof window.console !== "undefined") {
        console.log(a);
    }
</script>
:done: <em>Inspect this DOM element and the elements around it</em>
""")


Adding script tag here: :done: Inspect this DOM element and the elements around it

Check your webdev console

At this point it is useful to open your webdev console and see the output of the console.log command. You should also inspect the DOM node for the script


In [ ]: